package org.file5.controller;

import org.apache.log4j.Logger;
import org.file5.domain.EntityComment;
import org.file5.service.ServiceFascade;
import org.file5.util.DataBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.google.appengine.api.users.UserService;

@Controller
@RequestMapping("/snippet")
public class SnippetController {
	private final Logger logger = Logger.getLogger(this.getClass());

	@Autowired
	private ServiceFascade sf;
	@Autowired
	private UserService googleUserService;

	@RequestMapping(value = "/sidebar/latestcomments.htm", method = RequestMethod.GET)
	public String latestcomments(Model model) {
		DataBean<EntityComment> dbc = sf.getArticleService().getArticleComments(0, 10,null, null);
		if (dbc.getData() != null && !dbc.getData().isEmpty()) {
			model.addAttribute("articleComments", dbc.getData());
		}		
		return "snippet/sidebar_latest_comments";
	}


	@RequestMapping(value = "/sidebar/mostfamousarticles.htm", method = RequestMethod.GET)
	public String mostfamousarticles(Model model) {
		 		
		return "snippet/mostfamousarticles";
	}

}
